<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>类的定义和使用</title>
</head>
<body>
<script>
   /* //定义person类
    class Person{
        //构造方法
        constructor(name,age){
            this.name = name;
            this.age = age;
        }
        //show方法
        show(){
            document.write(this.name+","+this.age+"<br>");
        }
        //eat方法
        eat(){
            document.write("吃饭...");
        }
    }
    //使用person类
    let p = new Person("张三",23);
    p.show();
    p.eat();*/
   //定义person
    /*let person = {
        name : "张三",
        age : 23,
        hobby : ["听课","学习"],
        eat :function () {
            document.write("吃饭...")
        }
    }
    //使用person
    document.write(person.name+","+person.age+","+person.hobby[0]+","+person.hobby[1]+"<br>")
    person.eat()*/
    //定义worker类继承person类
   class Person{
       //构造方法
       constructor(name,age){
           this.name = name;
           this.age = age;
       }
       //eat方法
       eat(){
           document.write("吃饭...");
       }
   }
    class Worker extends  Person{
        constructor(name,age,salary){
            super(name,age);
            this.salary =salary;
       }
       show(){
            document.write(this.name+","+this.age+","+this.salary+"<br>")
       }
    }
    let w = new Worker("张三",23,50);
     w.show();
     w.eat();
</script>
</body>
</html>